/****************************************************************
 * Fulguro
 * Copyright (C) 2004 Christophe Clienti
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 ***************************************************************/

typedef struct {
  %immutable;
  int spp;
  int bps;
  FLGR_Type type;
  void *array;
  %mutable;
}FLGR_Vector;


%extend FLGR_Vector {
  /////////////////////////////////////////////////
  // Constructors & Destructors
  /////////////////////////////////////////////////
  
  FLGR_Vector(int spp, FLGR_Type type) {
    return flgr_vector_create(spp,type);
  }


  FLGR_Vector(FLGR_Vector *vec) {
    return flgr_vector_create(vec->spp, vec->type);
  }

  ~FLGR_Vector() {
    flgr_vector_destroy($self);
  }

  /////////////////////////////////////////////////
  // Operator overloading
  /////////////////////////////////////////////////
  FLGR_Vector *__add__(SwigObject value) {
    FLGR_Vector *vec = flgr_vector_create($self->spp,$self->type);
    FLGR_Vector *cst = flgr_vector_create($self->spp,$self->type);

    if($self->type == FLGR_BIT) {
      fgBIT val = (fgBIT) (CUInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_UINT8) {
      fgUINT8 val = (fgUINT8) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_UINT16) {
      fgUINT16 val = (fgUINT16) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_UINT32) {
      fgUINT32 val = (fgUINT32) (CUInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_UINT64) {
      fgUINT64 val = (fgUINT64) (CULongLong_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT8) {
      fgINT8 val = (fgINT8) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT16) {
      fgINT16 val = (fgINT16) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT32) {
      fgINT32 val = (fgINT32) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT64) {
      fgINT64 val = (fgINT64) (CLongLong_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_FLOAT32) {
      fgFLOAT32 val = (fgFLOAT32) (CFloat_FromSwigFloat(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_FLOAT64) {
      fgFLOAT64 val = (fgFLOAT64) (CDouble_FromSwigFloat(value));
      flgr_vector_populate_from_scalar(cst, &val);
    }

    flgr_vector_add(vec,$self,cst);

    flgr_vector_destroy(cst);

    return vec;
  }

  FLGR_Vector *__add__(FLGR_Vector *vec2) {
    FLGR_Vector *vec = flgr_vector_create($self->spp,$self->type);

    flgr_vector_add(vec,$self,vec2);

    return vec;
  }



  FLGR_Vector *__sub__(SwigObject value) {
    FLGR_Vector *vec = flgr_vector_create($self->spp,$self->type);
    FLGR_Vector *cst = flgr_vector_create($self->spp,$self->type);

    if($self->type == FLGR_BIT) {
      fgBIT val = (fgBIT) (CUInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_UINT8) {
      fgUINT8 val = (fgUINT8) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_UINT16) {
      fgUINT16 val = (fgUINT16) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_UINT32) {
      fgUINT32 val = (fgUINT32) (CUInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_UINT64) {
      fgUINT64 val = (fgUINT64) (CULongLong_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT8) {
      fgINT8 val = (fgINT8) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT16) {
      fgINT16 val = (fgINT16) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT32) {
      fgINT32 val = (fgINT32) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT64) {
      fgINT64 val = (fgINT64) (CLongLong_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_FLOAT32) {
      fgFLOAT32 val = (fgFLOAT32) (CFloat_FromSwigFloat(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_FLOAT64) {
      fgFLOAT64 val = (fgFLOAT64) (CDouble_FromSwigFloat(value));
      flgr_vector_populate_from_scalar(cst, &val);
    }

    flgr_vector_sub(vec,$self,cst);

    flgr_vector_destroy(cst);

    return vec;
  }

  FLGR_Vector *__sub__(FLGR_Vector *vec2) {
    FLGR_Vector *vec = flgr_vector_create($self->spp,$self->type);

    flgr_vector_sub(vec,$self,vec2);

    return vec;
  }

  FLGR_Vector *__mul__(SwigObject value) {
    FLGR_Vector *vec = flgr_vector_create($self->spp,$self->type);
    FLGR_Vector *cst = flgr_vector_create($self->spp,$self->type);

    if($self->type == FLGR_BIT) {
      fgBIT val = (fgBIT) (CUInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_UINT8) {
      fgUINT8 val = (fgUINT8) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_UINT16) {
      fgUINT16 val = (fgUINT16) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_UINT32) {
      fgUINT32 val = (fgUINT32) (CUInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_UINT64) {
      fgUINT64 val = (fgUINT64) (CULongLong_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT8) {
      fgINT8 val = (fgINT8) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT16) {
      fgINT16 val = (fgINT16) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT32) {
      fgINT32 val = (fgINT32) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT64) {
      fgINT64 val = (fgINT64) (CLongLong_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_FLOAT32) {
      fgFLOAT32 val = (fgFLOAT32) (CFloat_FromSwigFloat(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_FLOAT64) {
      fgFLOAT64 val = (fgFLOAT64) (CDouble_FromSwigFloat(value));
      flgr_vector_populate_from_scalar(cst, &val);
    }

    flgr_vector_mult(vec,$self,cst);

    flgr_vector_destroy(cst);

    return vec;
  }

  FLGR_Vector *__mul__(FLGR_Vector *vec2) {
    FLGR_Vector *vec = flgr_vector_create($self->spp,$self->type);
 
    flgr_vector_mult(vec,$self,vec2);

    return vec;
  }


  FLGR_Vector *__div__(SwigObject value) {
    FLGR_Vector *vec = flgr_vector_create($self->spp,$self->type);
    FLGR_Vector *cst = flgr_vector_create($self->spp,$self->type);

    if($self->type == FLGR_BIT) {
      fgBIT val = (fgBIT) (CUInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_UINT8) {
      fgUINT8 val = (fgUINT8) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_UINT16) {
      fgUINT16 val = (fgUINT16) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_UINT32) {
      fgUINT32 val = (fgUINT32) (CUInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_UINT64) {
      fgUINT64 val = (fgUINT64) (CULongLong_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT8) {
      fgINT8 val = (fgINT8) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT16) {
      fgINT16 val = (fgINT16) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT32) {
      fgINT32 val = (fgINT32) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT64) {
      fgINT64 val = (fgINT64) (CLongLong_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_FLOAT32) {
      fgFLOAT32 val = (fgFLOAT32) (CFloat_FromSwigFloat(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_FLOAT64) {
      fgFLOAT64 val = (fgFLOAT64) (CDouble_FromSwigFloat(value));
      flgr_vector_populate_from_scalar(cst, &val);
    }

    flgr_vector_div(vec,$self,cst);

    flgr_vector_destroy(cst);

    return vec;
  }

  FLGR_Vector *__div__(FLGR_Vector *vec2) {
    FLGR_Vector *vec = flgr_vector_create($self->spp,$self->type);
 
    flgr_vector_div(vec,$self,vec2);

    return vec;
  }

  SwigObject __eq__(SwigObject value) {
    FLGR_Vector *cst = flgr_vector_create($self->spp,$self->type);
    int tst;

    if($self->type == FLGR_BIT) {
      fgBIT val = (fgBIT) (CUInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_UINT8) {
      fgUINT8 val = (fgUINT8) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_UINT16) {
      fgUINT16 val = (fgUINT16) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_UINT32) {
      fgUINT32 val = (fgUINT32) (CUInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_UINT64) {
      fgUINT64 val = (fgUINT64) (CULongLong_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT8) {
      fgINT8 val = (fgINT8) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT16) {
      fgINT16 val = (fgINT16) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT32) {
      fgINT32 val = (fgINT32) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_INT64) {
      fgINT64 val = (fgINT64) (CLongLong_FromSwigInt(value));
      flgr_vector_populate_from_scalar(cst, &val);

    }else if($self->type == FLGR_FLOAT32) {
      fgFLOAT32 val = (fgFLOAT32) (CFloat_FromSwigFloat(value));
      flgr_vector_populate_from_scalar(cst, &val);
 
    }else if($self->type == FLGR_FLOAT64) {
      fgFLOAT64 val = (fgFLOAT64) (CDouble_FromSwigFloat(value));
      flgr_vector_populate_from_scalar(cst, &val);
    }

    tst = flgr_vector_equal($self,cst);

    flgr_vector_destroy(cst);

    return (tst) ? SwigTrue : SwigFalse;
  }


  SwigObject __eq__(FLGR_Vector *vec2) {
    int tst;

    tst = flgr_vector_equal($self,vec2);

    return (tst) ? SwigTrue : SwigFalse;
  }


  SwigObject __getitem__(int j) {
    SwigObject obj = SwigObjectEmpty;    

    if(j>=$self->spp) return SwigObjectEmpty;
    if(j<0) return SwigObjectEmpty;
   
    if($self->type==FLGR_UINT8) {
      fgUINT8 val;
      flgr_vector_get_element_fgUINT8($self,j,&val);
      obj = SwigInt_FromCUInt( (unsigned int) (val) );
      
    }else if($self->type==FLGR_UINT16) {
      fgUINT16 val;
      flgr_vector_get_element_fgUINT16($self,j,&val);
      obj = SwigInt_FromCInt( (int) (val) );
      
    }else if($self->type==FLGR_UINT32) {
      fgUINT32 val;
      flgr_vector_get_element_fgUINT32($self,j,&val);
      obj = SwigInt_FromCUInt( (unsigned int) (val) );
      
    }else if($self->type==FLGR_UINT64) {
      fgUINT64 val;
      flgr_vector_get_element_fgUINT64($self,j,&val);
      obj = SwigInt_FromCULongLong( (unsigned long long) (val) );
      
    }else if($self->type==FLGR_INT8) {
      fgINT8 val;
      flgr_vector_get_element_fgINT8($self,j,&val);
      obj = SwigInt_FromCInt( (int) (val) );
      
    }else if($self->type==FLGR_INT16) {
      fgINT16 val;
      flgr_vector_get_element_fgINT16($self,j,&val);
      obj = SwigInt_FromCInt( (int) (val) );
      
    }else if($self->type==FLGR_INT32) {
      fgINT32 val;
      flgr_vector_get_element_fgINT32($self,j,&val);
      obj = SwigInt_FromCInt( (int) (val) );
      
    }else if($self->type==FLGR_INT64) {
      fgINT64 val;
      flgr_vector_get_element_fgINT64($self,j,&val);
      obj = SwigInt_FromCLongLong( (long long) (val) );
      
    }else if($self->type==FLGR_FLOAT32) {
      fgFLOAT32 val;
      flgr_vector_get_element_fgFLOAT32($self,j,&val);
      obj = SwigFloat_FromCDouble( (double) (val) );
      
    }else if($self->type==FLGR_FLOAT64) {
      fgFLOAT64 val;
      flgr_vector_get_element_fgFLOAT64($self,j,&val);
      obj = SwigFloat_FromCDouble( (double) (val) );
      
    }else if($self->type==FLGR_BIT) {
      fgBIT val;
      flgr_vector_get_element_fgBIT($self,j,&val);
      obj = SwigInt_FromCUInt( (unsigned int) (val) );
      
    }else {
      POST_ERROR("type unknown\n");
      return SwigObjectEmpty;
    }
    
    return obj;
  }

  void __setitem__(int j, SwigObject value) {

    if(j>=$self->spp) return;
    if(j<0) return;

    if($self->type==FLGR_UINT8) {
      fgUINT8 c_value = (fgUINT8) (CInt_FromSwigInt(value));
      flgr_vector_set_element_fgUINT8($self,j,c_value);

    }else if($self->type==FLGR_UINT16) {
      fgUINT16 c_value = (fgUINT16) (CInt_FromSwigInt(value));
      flgr_vector_set_element_fgUINT16($self,j,c_value);
    
    }else if($self->type==FLGR_UINT32) {
      fgUINT32 c_value = (fgUINT32) (CUInt_FromSwigInt(value));
      flgr_vector_set_element_fgUINT32($self,j,c_value);
    
    }else if($self->type==FLGR_UINT64) {
      fgUINT64 c_value = (fgUINT64) (CULongLong_FromSwigInt(value));
      flgr_vector_set_element_fgUINT64($self,j,c_value);
    
    }else if($self->type==FLGR_INT8) {
      fgINT8 c_value = (fgINT8) (CInt_FromSwigInt(value));
      flgr_vector_set_element_fgINT8($self,j,c_value);
    
    }else if($self->type==FLGR_INT16) {
      fgINT16 c_value = (fgINT16) (CInt_FromSwigInt(value));
      flgr_vector_set_element_fgINT16($self,j,c_value);
    
    }else if($self->type==FLGR_INT32) {
      fgINT32 c_value = (fgINT32) (CInt_FromSwigInt(value));
      flgr_vector_set_element_fgINT32($self,j,c_value);
    
    }else if($self->type==FLGR_INT64) {
      fgINT64 c_value = (fgINT64) (CLongLong_FromSwigInt(value));
      flgr_vector_set_element_fgINT64($self,j,c_value);
    
    }else if($self->type==FLGR_FLOAT32) {
      fgFLOAT32 c_value = (fgFLOAT32) (CDouble_FromSwigFloat(value));
      flgr_vector_set_element_fgFLOAT32($self,j,c_value);
    
    }else if($self->type==FLGR_FLOAT64) {
      fgFLOAT64 c_value = (fgFLOAT64) (CDouble_FromSwigFloat(value));
      flgr_vector_set_element_fgFLOAT64($self,j,c_value);
    
    }else if($self->type==FLGR_BIT) {
      fgBIT c_value = (fgBIT) (CInt_FromSwigInt(value)!=0);
      flgr_vector_set_element_fgBIT($self,j,c_value);
    
    }else {
      POST_ERROR("unknown type\n");
      return ;
    }
  }




  /////////////////////////////////////////////////
  // Some methods incorporated in the class
  /////////////////////////////////////////////////



  void populate(SwigObject value) {
    if($self->type==FLGR_UINT8) {
      fgUINT8 c_value = (fgUINT8) (CUInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar_fgUINT8($self,c_value);

    }else if($self->type==FLGR_UINT16) {
      fgUINT16 c_value = (fgUINT16) (CUInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar_fgUINT16($self,c_value);
    
    }else if($self->type==FLGR_UINT32) {
      fgUINT32 c_value = (fgUINT32) (CUInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar_fgUINT32($self,c_value);
    
    }else if($self->type==FLGR_UINT64) {
      fgUINT64 c_value = (fgUINT64) (CULongLong_FromSwigInt(value));
      flgr_vector_populate_from_scalar_fgUINT64($self,c_value);
    
    }else if($self->type==FLGR_INT8) {
      fgINT8 c_value = (fgINT8) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar_fgINT8($self,c_value);
    
    }else if($self->type==FLGR_INT16) {
      fgINT16 c_value = (fgINT16) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar_fgINT16($self,c_value);
    
    }else if($self->type==FLGR_INT32) {
      fgINT32 c_value = (fgINT32) (CInt_FromSwigInt(value));
      flgr_vector_populate_from_scalar_fgINT32($self,c_value);
    
    }else if($self->type==FLGR_INT64) {
      fgINT64 c_value = (fgINT64) (CLongLong_FromSwigInt(value));
      flgr_vector_populate_from_scalar_fgINT64($self,c_value);
    
    }else if($self->type==FLGR_FLOAT32) {
      fgFLOAT32 c_value = (fgFLOAT32) (CFloat_FromSwigFloat(value));
      flgr_vector_populate_from_scalar_fgFLOAT32($self,c_value);
    
    }else if($self->type==FLGR_FLOAT64) {
      fgFLOAT64 c_value = (fgFLOAT64) (CDouble_FromSwigFloat(value));
      flgr_vector_populate_from_scalar_fgFLOAT64($self,c_value);
    
    }else if($self->type==FLGR_BIT) {
      fgBIT c_value = (fgBIT) (CUInt_FromSwigInt(value)!=0);
       flgr_vector_populate_from_scalar_fgBIT($self,c_value);
  
    }else {
      POST_ERROR("unknown type\n");
      return ;
    }
  }

  void from_raw(SwigObject obj) {
    int size = $self->spp;
    int i;

    if($self->type==FLGR_UINT8) {
      fgUINT8 val;
      for(i=0 ; i<size ; i++) {
	val = (fgUINT8) (CUInt_FromSwigInt(SwigGetArrayVal(obj,i)));
	flgr_vector_set_element_fgUINT8($self,i,val);
      }

    }else if($self->type==FLGR_UINT16) {	
      fgUINT16 val;
      for(i=0 ; i<size ; i++) {
	val = (fgUINT16) (CUInt_FromSwigInt(SwigGetArrayVal(obj,i)));
	flgr_vector_set_element_fgUINT16($self,i,val);
      }
    
    }else if($self->type==FLGR_UINT32) {	
      fgUINT32 val;
      for(i=0 ; i<size ; i++) {
	val = (fgUINT32) (CUInt_FromSwigInt(SwigGetArrayVal(obj,i)));
	flgr_vector_set_element_fgUINT32($self,i,val);
      }
    
    }else if($self->type==FLGR_UINT64) {	
      fgUINT64 val;
      for(i=0 ; i<size ; i++) {
	val = (fgUINT64) (CULongLong_FromSwigInt(SwigGetArrayVal(obj,i)));
	flgr_vector_set_element_fgUINT64($self,i,val);
      }
    
    }else if($self->type==FLGR_INT8) {	
      fgINT8 val;
      for(i=0 ; i<size ; i++) {
	val = (fgINT8) (CInt_FromSwigInt(SwigGetArrayVal(obj,i)));
	flgr_vector_set_element_fgINT8($self,i,val);
      }
    
    }else if($self->type==FLGR_INT16) {	
      fgINT16 val;
      for(i=0 ; i<size ; i++) {
	val = (fgINT16) (CInt_FromSwigInt(SwigGetArrayVal(obj,i)));
	flgr_vector_set_element_fgINT16($self,i,val);
      }
    
    }else if($self->type==FLGR_INT32) {	
      fgINT32 val;
      for(i=0 ; i<size ; i++) {
	val = (fgINT32) (CInt_FromSwigInt(SwigGetArrayVal(obj,i)));
	flgr_vector_set_element_fgINT32($self,i,val);
      }
   
    }else if($self->type==FLGR_INT64) {	
      fgINT64 val;
      for(i=0 ; i<size ; i++) {
	val = (fgINT64) (CLongLong_FromSwigInt(SwigGetArrayVal(obj,i)));
	flgr_vector_set_element_fgINT64($self,i,val);
      }
   
    }else if($self->type==FLGR_FLOAT32) {		
      fgFLOAT32 val;
      for(i=0 ; i<size ; i++) {
	val = (fgFLOAT32) (CInt_FromSwigInt(SwigGetArrayVal(obj,i)));
	flgr_vector_set_element_fgFLOAT32($self,i,val);
      }
    
    }else if($self->type==FLGR_FLOAT64) {	
      fgFLOAT64 val;
      for(i=0 ; i<size ; i++) {
	val = (fgFLOAT64) (CInt_FromSwigInt(SwigGetArrayVal(obj,i)));
	flgr_vector_set_element_fgFLOAT64($self,i,val);
      }

    }else if($self->type==FLGR_BIT) {	
      fgBIT val;
      for(i=0 ; i<size ; i++) {
	val = (fgBIT) (CInt_FromSwigInt(SwigGetArrayVal(obj,i)));
	flgr_vector_set_element_fgBIT($self,i,val);
      }
    
    }else {					
      POST_ERROR("unknown type\n");
    }
  }

  SwigObject to_raw() {
    int i;
    SwigObject obj = SwigObjectEmpty;    

    obj = SwigCreateArray($self->spp);

    if($self->type==FLGR_UINT8) {
      fgUINT8 val;
      for(i=0 ; i<$self->spp ; i++) {
	flgr_vector_get_element_fgUINT8($self,i,&val);
	SwigSetArrayVal( obj, i, SwigInt_FromCUInt((unsigned int) val) );
      }
      
    }else if($self->type==FLGR_UINT16) {
      fgUINT16 val;
      for(i=0 ; i<$self->spp ; i++) {
	flgr_vector_get_element_fgUINT16($self,i,&val);
	SwigSetArrayVal( obj, i, SwigInt_FromCUInt((unsigned int) val) );
      }
      
    }else if($self->type==FLGR_UINT32) {
      fgUINT32 val;
      for(i=0 ; i<$self->spp ; i++) {
	flgr_vector_get_element_fgUINT32($self,i,&val);
	SwigSetArrayVal( obj, i, SwigInt_FromCUInt(val) );
      }
      
    }else if($self->type==FLGR_UINT64) {
      fgUINT64 val;
      for(i=0 ; i<$self->spp ; i++) {
	flgr_vector_get_element_fgUINT64($self,i,&val);
	SwigSetArrayVal( obj, i, SwigInt_FromCULongLong(val) );
      }
      
    }else if($self->type==FLGR_INT8) {
      fgINT8 val;
      for(i=0 ; i<$self->spp ; i++) {
	flgr_vector_get_element_fgINT8($self,i,&val);
	SwigSetArrayVal( obj, i, SwigInt_FromCInt((int) val) );
      }
      
    }else if($self->type==FLGR_INT16) {
      fgINT16 val;
      for(i=0 ; i<$self->spp ; i++) {
	flgr_vector_get_element_fgINT16($self,i,&val);
	SwigSetArrayVal( obj, i, SwigInt_FromCInt((int) val) );
      }
     
    }else if($self->type==FLGR_INT32) {
      fgINT32 val;
      for(i=0 ; i<$self->spp ; i++) {
	flgr_vector_get_element_fgINT32($self,i,&val);
	SwigSetArrayVal( obj, i, SwigInt_FromCInt((int) val) );
      }
       
    }else if($self->type==FLGR_INT64) {
      fgINT64 val;
      for(i=0 ; i<$self->spp ; i++) {
	flgr_vector_get_element_fgINT64($self,i,&val);
	SwigSetArrayVal( obj, i, SwigInt_FromCLongLong((int) val) );
      }
       
    }else if($self->type==FLGR_FLOAT32) {
      fgFLOAT32 val;
      for(i=0 ; i<$self->spp ; i++) {
	flgr_vector_get_element_fgFLOAT32($self,i,&val);
	SwigSetArrayVal( obj, i, SwigFloat_FromCDouble((double) val) );
      }
       
    }else if($self->type==FLGR_FLOAT64) {
      fgFLOAT64 val;
      for(i=0 ; i<$self->spp ; i++) {
	flgr_vector_get_element_fgFLOAT64($self,i,&val);
	SwigSetArrayVal( obj, i, SwigFloat_FromCDouble(val) );
      }
     
    }else if($self->type==FLGR_BIT) {
      fgBIT val;
      for(i=0 ; i<$self->spp ; i++) {
	flgr_vector_get_element_fgBIT($self,i,&val);
	SwigSetArrayVal( obj, i, SwigInt_FromCUInt((unsigned int) val) );
      }

    }else {
      POST_ERROR("type unknown\n");
      return SwigObjectEmpty;
    }
    
    return obj;
  }

  void from_string(SwigObject obj) {
    char *str = CString_FromSwigString(obj);
    flgr_vector_import_raw($self, (void *) str);
  }

  SwigObject to_string() {
    SwigObject obj;
    void *str = malloc($self->spp * flgr_get_sizeof($self->type));
    flgr_vector_export_raw(str,$self);
    obj = SwigString_FromCString(str);
    free(str);
    return obj;
  }



};








%feature("autodoc","""
[out] FLGR_Vector
[int] FLGR_Vector
[return] FLGR_Ret\n
revert all elements of a vector
""") flgr_vector_revert_element;
FLGR_Ret flgr_vector_revert_element(FLGR_Vector *vctdest, FLGR_Vector *vctsrc);


%feature("autodoc","""
[in] FLGR_Vector
[return] FLGR_Ret\n
Set all vector elements to zero
""") flgr_vector_clear;
FLGR_Ret flgr_vector_clear(FLGR_Vector *vct);

%feature("autodoc","""
[in] FLGR_Vector
[in] FLGR_Vector
[return] Integer 
Return 1 if all vectors elements are equals
""") flgr_vector_equal;
int flgr_vector_equal(FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Return FLGR_RET_OK if vectors have same type
""") flgr_vector_is_same_type;
FLGR_Ret flgr_vector_is_same_type(FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Return FLGR_RET_OK if vectors have same spp
""") flgr_vector_is_same_spp;
FLGR_Ret flgr_vector_is_same_spp(FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Copy a vector
""") flgr_vector_copy;
FLGR_Ret flgr_vector_copy(FLGR_Vector *vctdest, FLGR_Vector *vctsrc);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute inf over vectors elements
""") flgr_vector_inf;
FLGR_Ret flgr_vector_inf(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute sup over vectors elements
""") flgr_vector_sup;
FLGR_Ret flgr_vector_sup(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute add over vectors elements
""") flgr_vector_add;
FLGR_Ret flgr_vector_add(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute sub over vectors elements
""") flgr_vector_sub;
FLGR_Ret flgr_vector_sub(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute mult over vectors elements
""") flgr_vector_mult;
FLGR_Ret flgr_vector_mult(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute div over vectors elements
""") flgr_vector_div;
FLGR_Ret flgr_vector_div(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute addsat over vectors elements
""") flgr_vector_addsat;
FLGR_Ret flgr_vector_addsat(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute subsat over vectors elements
""") flgr_vector_subsat;
FLGR_Ret flgr_vector_subsat(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute multsat over vectors elements
""") flgr_vector_multsat;
FLGR_Ret flgr_vector_multsat(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute atan2 over vectors elements
""") flgr_vector_atan2;
FLGR_Ret flgr_vector_atan2(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute abs over vector elements
""") flgr_vector_abs;
FLGR_Ret flgr_vector_abs(FLGR_Vector *vctdest, FLGR_Vector *vct1);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute cos over vector elements
""") flgr_vector_cos;
FLGR_Ret flgr_vector_cos(FLGR_Vector *vctdest, FLGR_Vector *vct1);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute sin over vector elements
""") flgr_vector_sin;
FLGR_Ret flgr_vector_sin(FLGR_Vector *vctdest, FLGR_Vector *vct1);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute tan over vector elements
""") flgr_vector_tan;
FLGR_Ret flgr_vector_tan(FLGR_Vector *vctdest, FLGR_Vector *vct1);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute asin over vector elements
""") flgr_vector_asin;
FLGR_Ret flgr_vector_asin(FLGR_Vector *vctdest, FLGR_Vector *vct1);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute acos over vector elements
""") flgr_vector_acos;
FLGR_Ret flgr_vector_acos(FLGR_Vector *vctdest, FLGR_Vector *vct1);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute atan over vector elements
""") flgr_vector_atan;
FLGR_Ret flgr_vector_atan(FLGR_Vector *vctdest, FLGR_Vector *vct1);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute floor over vector elements
""") flgr_vector_floor;
FLGR_Ret flgr_vector_floor(FLGR_Vector *vctdest, FLGR_Vector *vct1);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute ceil over vector elements
""") flgr_vector_ceil;
FLGR_Ret flgr_vector_ceil(FLGR_Vector *vctdest, FLGR_Vector *vct1);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute square of vector elements
""") flgr_vector_square;
FLGR_Ret flgr_vector_square(FLGR_Vector *vctdest, FLGR_Vector *vct1);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute square root of vector elements
""") flgr_vector_sqrt;
FLGR_Ret flgr_vector_sqrt(FLGR_Vector *vctdest, FLGR_Vector *vct1);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute logb over vectors elements
""") flgr_vector_logb;
FLGR_Ret flgr_vector_logb(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute powb over vectors elements
""") flgr_vector_powb;
FLGR_Ret flgr_vector_powb(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute not over vector elements
""") flgr_vector_not;
FLGR_Ret flgr_vector_not(FLGR_Vector *vctdest, FLGR_Vector *vct1);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute and over vectors elements
""") flgr_vector_and;
FLGR_Ret flgr_vector_and(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute or over vectors elements
""") flgr_vector_or;
FLGR_Ret flgr_vector_or(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute xor over vectors elements
""") flgr_vector_xor;
FLGR_Ret flgr_vector_xor(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute nand over vectors elements
""") flgr_vector_nand;
FLGR_Ret flgr_vector_nand(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compute nor over vectors elements
""") flgr_vector_nor;
FLGR_Ret flgr_vector_nor(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compare vector elements and store each result in a vector
""") flgr_vector_cmp_ne;
FLGR_Ret flgr_vector_cmp_ne(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compare vector elements and store each result in a vector
""") flgr_vector_cmp_eq;
FLGR_Ret flgr_vector_cmp_eq(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compare vector elements and store each result in a vector
""") flgr_vector_cmp_ge;
FLGR_Ret flgr_vector_cmp_ge(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compare vector elements and store each result in a vector
""") flgr_vector_cmp_le;
FLGR_Ret flgr_vector_cmp_le(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compare vector elements and store each result in a vector
""") flgr_vector_cmp_gt;
FLGR_Ret flgr_vector_cmp_gt(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector
[in] FLGR_Vector
[in] FLGR_Vector
[return] FLGR_Ret\n
Compare vector elements and store each result in a vector
""") flgr_vector_cmp_lt;
FLGR_Ret flgr_vector_cmp_lt(FLGR_Vector *vctdest, FLGR_Vector *vct1, FLGR_Vector *vct2);

%feature("autodoc","""
[out] FLGR_Vector vector dest
[in] FLGR_Vector comparision
[in] FLGR_Vector vector to move
[return] FLGR_Ret\n
Conditional move vectors elements\n
Example : dest[n] = ( comp[n] != 0 ? src[n] : dest[n] )
""") flgr_vector_cmove;
FLGR_Ret flgr_vector_cmove(FLGR_Vector *vctdest, FLGR_Vector *vctcmp, FLGR_Vector *vct); 







  












